package com.wanhelibs.custom_view.views;

import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.ListView;
import android.widget.TextView;

import com.wanhe.base.BaseDialogFragment;
import com.wanhe.base.model.base.Dish;
import com.wanhelibs.R;
import com.wanhelibs.adapter.TagSelectAdapter;

/**
 * Created by XieZaiWei on 2017/8/9.
 * 口味加减Dialog
 */

public class TagSelectDialog extends BaseDialogFragment {

	private TextView tv_title;
	private ListView lv_tag;

	private Dish mDish;

	public static TagSelectDialog newInstance() {
		TagSelectDialog dialog = new TagSelectDialog();
		return dialog;
	}

	public void setDish(Dish dish) {
		mDish = dish;
	}

	@Override
	public void onCreate(@Nullable Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
							 Bundle savedInstanceState) {
		getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
		getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
		mView = inflater.inflate(R.layout.tag_select_dialog, container, false);
		return mView;
	}

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		tv_title = (TextView) findViewById(R.id.tv_title);
		lv_tag = (ListView) findViewById(R.id.lv_tag);

		tv_title.setText(mDish.getVch_dishname());
		init();
	}

	private void init(){
		TagSelectAdapter tagSelectAdapter = new TagSelectAdapter(getContext(), mDish);
		lv_tag.setAdapter(tagSelectAdapter);
	}

}
